package cn.fx.feignClient;

import cn.fx.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFallbackFactory implements FallbackFactory<UserFeignClient> {

    // 此方法创建降级类
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1L,"熔断","网络异常，稍后重试");
            }
        };
    }
}
